package view.role;

import java.util.List;
import trans.BaseTransBean;
import trans.RoleInfoTrans;
import utils.UtilsBean;
import net.sf.json.JSONArray;
import net.sf.json.JsonConfig;
import com.opensymphony.xwork2.ActionSupport;
import data.RoleInfoBean;

public class RoleInfoListAction extends ActionSupport {
	private JSONArray roleList;
	private String deptno;

	public JSONArray getRoleList() {
		return roleList;
	}

	public void setRoleList(JSONArray roleList) {
		this.roleList = roleList;
	}

	public String getDeptno() {
		return deptno;
	}

	public void setDeptno(String deptno) {
		this.deptno = deptno;
	}

	@Override
		public String execute() throws Exception {
		try{
			RoleInfoTrans trans = new RoleInfoTrans(false);
			List<RoleInfoBean>  roles = trans.queryRoleInfo(deptno);	
			JsonConfig jsonConfig = new JsonConfig();
			String[] excludsField = {"callback"}; 
			jsonConfig.setExcludes(excludsField);
			roleList = JSONArray.fromObject(roles, jsonConfig);
			return SUCCESS;
		}catch (Exception ex){
			UtilsBean.writeErrStack(ex);
			UtilsBean.writeLogInfo(ex.getMessage());
			return SUCCESS;
		}
		finally{
			BaseTransBean.closeDaoSession();
		}
	}
}
